package com.ruoyi.web.controller.applet;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.HospitalSubscribeGroupPurchaseOrderApplyFor;
import com.ruoyi.system.service.IHospitalSubscribeGroupPurchaseOrderApplyForService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 团队订单申请Controller
 * 
 * @author ruoyi
 * @date 2025-06-12
 */
@RestController
@RequestMapping("/applet/for")
public class HospitalSubscribeGroupPurchaseOrderApplyForAppletController extends BaseController
{
    @Autowired
    private IHospitalSubscribeGroupPurchaseOrderApplyForService hospitalSubscribeGroupPurchaseOrderApplyForService;

    /**
     * 查询团队订单申请列表
     */
    @GetMapping("/list")
    public TableDataInfo list(HospitalSubscribeGroupPurchaseOrderApplyFor hospitalSubscribeGroupPurchaseOrderApplyFor)
    {
        startPage();
        hospitalSubscribeGroupPurchaseOrderApplyFor.setLinkmanPhone(SecurityUtils.getLoginUser().getUser().getPhonenumber());
        List<HospitalSubscribeGroupPurchaseOrderApplyFor> list = hospitalSubscribeGroupPurchaseOrderApplyForService.selectHospitalSubscribeGroupPurchaseOrderApplyForList(hospitalSubscribeGroupPurchaseOrderApplyFor);
        return getDataTable(list);
    }

    /**
     * 导出团队订单申请列表
     */
    @Log(title = "团队订单申请", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HospitalSubscribeGroupPurchaseOrderApplyFor hospitalSubscribeGroupPurchaseOrderApplyFor)
    {
        List<HospitalSubscribeGroupPurchaseOrderApplyFor> list = hospitalSubscribeGroupPurchaseOrderApplyForService.selectHospitalSubscribeGroupPurchaseOrderApplyForList(hospitalSubscribeGroupPurchaseOrderApplyFor);
        ExcelUtil<HospitalSubscribeGroupPurchaseOrderApplyFor> util = new ExcelUtil<HospitalSubscribeGroupPurchaseOrderApplyFor>(HospitalSubscribeGroupPurchaseOrderApplyFor.class);
        util.exportExcel(response, list, "团队订单申请数据");
    }

    /**
     * 获取团队订单申请详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(hospitalSubscribeGroupPurchaseOrderApplyForService.selectHospitalSubscribeGroupPurchaseOrderApplyForById(id));
    }

    /**
     * 新增团队订单申请
     */
    @Log(title = "团队订单申请", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HospitalSubscribeGroupPurchaseOrderApplyFor hospitalSubscribeGroupPurchaseOrderApplyFor)
    {
        return toAjax(hospitalSubscribeGroupPurchaseOrderApplyForService.insertHospitalSubscribeGroupPurchaseOrderApplyFor(hospitalSubscribeGroupPurchaseOrderApplyFor));
    }

    /**
     * 修改团队订单申请
     */
    @Log(title = "团队订单申请", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HospitalSubscribeGroupPurchaseOrderApplyFor hospitalSubscribeGroupPurchaseOrderApplyFor)
    {
        return toAjax(hospitalSubscribeGroupPurchaseOrderApplyForService.updateHospitalSubscribeGroupPurchaseOrderApplyFor(hospitalSubscribeGroupPurchaseOrderApplyFor));
    }

    /**
     * 删除团队订单申请
     */
    @Log(title = "团队订单申请", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(hospitalSubscribeGroupPurchaseOrderApplyForService.deleteHospitalSubscribeGroupPurchaseOrderApplyForByIds(ids));
    }
}
